﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace UI
{
    public partial class Ftest : Form
    {
        private AccountManagement AccountMag = new AccountManagement();
        public Ftest()
        {
           
            InitializeComponent();
            AccountMag.LoadDataFromFile();  //用account.xml文件中的数据填充 AccountMag.AccountList
        }

        /// <summary>
        /// 删除
        /// </summary>
        private void BtnDel_Click(object sender, EventArgs e)
        {
            this.AccountMag.DelAccount(1);
        }
        /// <summary>
        /// 添加
        /// </summary>
        private void BtnAdd_Click_1(object sender, EventArgs e)
        {
            Account acc = new Account();
            acc.ID = 1;
            acc.Name = "1";
            acc.Color = 1;
            acc.CreatedTime = DateTime.Parse("2010-10-09");
            acc.ModifiedTime = DateTime.Parse("2010-10-09");
            acc.Balance = 1;
            this.AccountMag.AddAccount(acc);
            //注意，连续添加时，必须新建两个不同的对象，如acc与acc1。否则，会重复添加最后一项
            Account acc1 = new Account();
            acc1.ID = 2;
            acc1.Name = "2";
            acc1.Color = 2;
            acc1.CreatedTime = DateTime.Parse("2010-10-09");
            acc1.ModifiedTime = DateTime.Parse("2010-10-09");
            acc1.Balance = 2;
            this.AccountMag.AddAccount(acc1);
        }

        /// <summary>
        /// 更新
        /// </summary>
        private void BtnUpdate_Click(object sender, EventArgs e)
        {
            Account acc = new Account();
            acc.ID = 1;
            acc.Name = "3";
            acc.Color = 3;
            acc.CreatedTime = DateTime.Parse("2010-10-09");
            acc.ModifiedTime = DateTime.Parse("2010-10-09");
            acc.Balance = 3;
            this.AccountMag.UpdateAccount(acc);
        }
    }
}
